package com.songlanyun.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonValue;
import com.songlanyun.common.drive.IntegerEnum;

import java.util.Objects;

/**
 *
 */
public class SysConstant {

    public static final String CN_AREA_MAP_REDIS_KEY = "sys:cnarea:map";
    public static final String CN_AREA_TREE_REDIS_KEY = "sys:cnarea:tree";

    public static final Integer PT_ADMIN_ROLE = 1;//平台管理员角色
    public static final Integer PT_SHOP_ADMIN_ROLE = 2;//平台商家管理员角色
    public static final Integer JM_SHOP_ADMIN_ROLE = 3;//加盟商家管理员角色
    public static final Integer AREA_AGENT_ADMIN_ROLE = 4;//区域代理管理员角色
    public static final Integer OTHER_ROLE = 0;//其他管理员角色


    /**
     * 图片类型
     * * 0 'goods' :商品
     * * 1 'news'：新闻
     * * 2 'opus'：作品
     * * 3 'comment'：评论
     * * 4 'rights'：维权
     * * 5 'other'：其它
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum ResourceType implements IntegerEnum<Integer> {

        GOODS(0, "商品"),
        NEWS(1, "新闻"),
        OPUS(2, "作品"),
        COMMENT(3, "评论"),
        RIGHTS(4, "维权"),
        OTHER(5, "其它"),
        ;

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        ResourceType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static ResourceType getByCode(int code) {
            for (ResourceType value : ResourceType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 互动消息类型
     * 0：作品互动
     * 1：用户关注
     * 2：作品审核
     * 3：网红审核
     * 4：商家审核
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum InteractionType implements IntegerEnum<Integer> {

        OPUS_INTERACTION(0, "作品互动"),
        USER_CONCERN(1, "用户关注"),
        OPUS_CHECK(2, "作品审核"),
        NETRED_CHECK(3, "网红审核"),
        SHOP_CHECK(4, "商家审核"),
        UNION_BUSINESS_CHECK(5, "联盟商家审核"),
        ;

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        InteractionType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static InteractionType getByCode(int code) {
            for (InteractionType value : InteractionType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 系统消息类型
     * 0：区县运营商审核消息
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum SystemMessageType implements IntegerEnum<Integer> {
        AREA_AGENT_CHECK(0, "区县运营商审核消息"),
        ;

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        SystemMessageType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static SystemMessageType getByCode(int code) {
            for (SystemMessageType value : SystemMessageType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

}
